<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./lib/axios.min.js"></script>
</head>
<body>
    <button>发送请求</button>
    <button>取消请求</button>
</body>
<script>
	const btns = document.querySelectorAll("button");
	let cancelHandler = null;
	btns[0].onclick = function () {
		axios.get("http://zhangpeiyue.com/scoreList",{
			timeout:1000,
			cancelToken:new axios.CancelToken(function(cancel){
				cancelHandler = cancel;
            })
        }).then(value => {
			console.log(value.data);
		}).catch(err => {
			console.log("err",axios.isCancel(err));
		})
	}
	btns[1].onclick = function(){
        if(cancelHandler) cancelHandler();
    }

</script>
</html>